package config

import (
	"encoding/json"
	"io/ioutil"
	"log"
)

//rabbitmqConfig rabbitmq配置信息
type rabbitmqConfig struct {
	//是否启用异步传输
	EnableAsyncTransfer bool `json:"enableAsyncTransfer"`
	//rabbitmqURL
	RabbitmqURL string `json:"rabbitmqURL"`
	//传输交换机名
	TransExchangeName string `json:"transExchangeName"`
	//OSS传输队列名
	TransOSSQueueName string `json:"transOSSQueueName"`
	//OSS传输路由键
	TransOSSRoutingKey string `json:"transOSSRoutingKey"`
}

var RabbitMQCfg *rabbitmqConfig

func init() {
	bytes, err := ioutil.ReadFile("../../config/rabbitmq_config.json")
	if err != nil {
		log.Fatalf("读取rabbitmq配置信息异常：%v", err.Error())
	}
	//log.Println(string(bytes))
	RabbitMQCfg = &rabbitmqConfig{}
	if err = json.Unmarshal(bytes, RabbitMQCfg); err != nil {
		log.Panicf("解析rabbitmq_config.json失败", err.Error())
	}
	log.Println("解析rabbitmq配置信息成功")
}
